package cn.geminis.lowcode.compiler.code;

import cn.geminis.lowcode.compiler.util.JdkTreeMakerUtils;
import com.sun.source.tree.AssignmentTree;
import com.sun.source.tree.ExpressionTree;
import lombok.RequiredArgsConstructor;

/**
 * @author puddi
 */
@RequiredArgsConstructor
public class LcAssign extends AbstractExpression<AssignmentTree> {
    private final AbstractCode<?, ?> target;
    private final AbstractExpression<?> then;

    public LcAssign(String ident, AbstractExpression<?> then) {
        this(new LcIdent(ident), then);
    }

    @Override
    protected AssignmentTree createJdkTree() {
        return JdkTreeMakerUtils.assign(
                target.createJdkTree(),
                (ExpressionTree) then.createJdkTree()
        );
    }

}
